#ifndef _TCPSOCKET_H_
#define _TCPSOCKET_H_

class ServerAddress
{
private:
    struct sockaddr_in server_addr;

public:
    ServerAddress(const std::string& ip, int port);
    // 获取服务器地址结构
    const struct sockaddr_in& getServerAddress() const;
};

class TcpServer
{
private:
    int m_serverfd;
    int m_port;
    ServerAddress *server_addr;

public:

    TcpServer(int port):m_serverfd(-1), m_port(port)
    {
        createSocket();
        bindSocket();
        listenSocket();
    }
    void createSocket();
    void bindSocket();
    void listenSocket();
    void acceptConnection();
    void start();

    ~TcpServer();
};

class TcpClient
{
private:
    int m_sockfd;
    int m_serverPort;
    std::string m_serverIP;

public:

    TcpClient(const std::string& serverIP, int serverPort);
    ~TcpClient();
};

#endif